package com.example.test_1;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class ActivityChuanCan2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chuan_can2);

        TextView content = findViewById(R.id.textView);

        //方式一的
        /*Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        int age = intent.getIntExtra("age", 0);
        content.setText("姓名：" + name +"年龄:" + age);*/


        //方式二
        Bundle extras = getIntent().getExtras();
        String name = extras.getString("name");
        int age = extras.getInt("age");
        content.setText("姓名：" + name +"年龄:" + age);


    }

    // 第二步在chuancan2中添加一个返回按钮并添加一个点击事件，返回的时候调用setResult
    public void fanH(View view) {
        Intent intent = new Intent();
        intent.putExtra("result","我是第二个页面返回的数据");
        setResult(RESULT_OK,intent);
        finish();
    }
}